
    ##############################################################################################
    # R code to replicate
    # Figure 4 of Measuring Foreign Policy Positions of Members of the US Congress
    ### Note: Implement this after executing R code for Figure 3
    ### You need "Summary_Outputs.csv", which will be created by MCMC estimation for Figure 3
    ##############################################################################################

    T <- 33  # number of congresses
    year.odd <- seq(from=1945, to=2010, by=2)

    Outputs <- read.csv("Summary_Outputs.csv", header=T) # Summary of Estimates from Figure 3 Estimation
    
    # Select key senators    
    Mccain     <- Outputs[Outputs$ICPSR_ID==15039,]        
    Fulbright  <- Outputs[Outputs$ICPSR_ID==3388,]        
    Kerry      <- Outputs[Outputs$ICPSR_ID==14920,]  
    Lugar      <- Outputs[Outputs$ICPSR_ID==14506,]
    Jackson    <- Outputs[Outputs$ICPSR_ID==4851,] # Henry "Scoop" Jackson (D-WA)
    Vandenberg <- Outputs[Outputs$ICPSR_ID==9604,] 
    Dirksen    <- Outputs[Outputs$ICPSR_ID==2609,]


    postscript("Figure4.eps", height=12, width=10, horizontal=F)
    par(mfrow=c(2, 1))
    plot(1:T, 1:T, type='n', col='blue', cex=.7, xlim=c(0.5, T+3), ylim=c(-3,3), xaxt="n", xlab="",ylab="")
    axis(side=1, las=3, at=1:T, labels=year.odd, cex.axis=.8)

    points(Jackson$time, Jackson$IRT_mean,  type='o', lty=1, col='blue', cex=.7)
    points(Jackson$time, Jackson$DW_NOM1,  type='o', lty=2, col='black', cex=.7)
    segments(Jackson$time, Jackson$IRT_2.5Q, Jackson$time, Jackson$IRT_97.5Q, col='blue')
    segments(Jackson$time, Jackson$DW_NOM1 + 2*Jackson$DW_NOM1_se, Jackson$time, Jackson$DW_NOM1 - 2*Jackson$DW_NOM1_se, col='black')
    text(max(Jackson$time)+2, Jackson$IRT_mean[length(Jackson$IRT_mean)], label="Jackson (D)", cex=.7)

    points(Vandenberg$time, Vandenberg$IRT_mean,  type='o', lty=1, col='red', cex=.7)
    points(Vandenberg$time, Vandenberg$DW_NOM1,  type='o', lty=2, col='black', cex=.7)
    segments(Vandenberg$time, Vandenberg$IRT_2.5Q, Vandenberg$time, Vandenberg$IRT_97.5Q, col='red')
    segments(Vandenberg$time, Vandenberg$DW_NOM1 + 2*Vandenberg$DW_NOM1_se, Vandenberg$time, Vandenberg$DW_NOM1 - 2*Vandenberg$DW_NOM1_se, col='black')
    text(max(Vandenberg$time)+2.2, Vandenberg$IRT_mean[length(Vandenberg$IRT_mean)], label="Vandenberg (R)", cex=.7)

    points(Lugar$time, Lugar$IRT_mean,  type='o', lty=1, col='red', cex=.7)
    points(Lugar$time, Lugar$DW_NOM1,  type='o', lty=2, col='black', cex=.7)
    segments(Lugar$time, Lugar$IRT_2.5Q, Lugar$time, Lugar$IRT_97.5Q, col='red')
    segments(Lugar$time, Lugar$DW_NOM1 + 2*Lugar$DW_NOM1_se, Lugar$time, Lugar$DW_NOM1 - 2*Lugar$DW_NOM1_se, col='black')
    text(max(Lugar$time)+1.8, Lugar$IRT_mean[length(Lugar$IRT_mean)], label="Lugar (R)", cex=.7)

    plot(1:T, 1:T, type='n', col='blue', cex=.7, xlim=c(0.5, T+3), ylim=c(-3,3), xaxt="n", xlab="",ylab="")
    axis(side=1, las=3, at=1:T, labels=year.odd, cex.axis=.8)

    points(Kerry$time, Kerry$IRT_mean,  type='o', lty=1, col='blue', cex=.7)
    points(Kerry$time, Kerry$DW_NOM1,  type='o', lty=2, col='black', cex=.7)
    segments(Kerry$time, Kerry$IRT_2.5Q, Kerry$time, Kerry$IRT_97.5Q, col='blue')
    segments(Kerry$time, Kerry$DW_NOM1 + 2*Kerry$DW_NOM1_se, Kerry$time, Kerry$DW_NOM1 - 2*Kerry$DW_NOM1_se, col='black')
    text(max(Kerry$time)+1.8, Kerry$IRT_mean[length(Kerry$IRT_mean)], label="Kerry (D)", cex=.7)

    points(Mccain$time, Mccain$IRT_mean,  type='o', lty=1, col='red', cex=.7)
    points(Mccain$time, Mccain$DW_NOM1,  type='o', lty=2, col='black', cex=.7)
    segments(Mccain$time, Mccain$IRT_2.5Q, Mccain$time, Mccain$IRT_97.5Q, col='red')
    segments(Mccain$time, Mccain$DW_NOM1 + 2*Mccain$DW_NOM1_se, Mccain$time, Mccain$DW_NOM1 - 2*Mccain$DW_NOM1_se, col='black')
    text(max(Mccain$time)+1.8, Mccain$IRT_mean[length(Mccain$IRT_mean)], label="McCain (R)", cex=.7)

    points(Fulbright$time, Fulbright$IRT_mean,  type='o', lty=1, col='blue', cex=.7)
    points(Fulbright$time, Fulbright$DW_NOM1,  type='o', lty=2, col='black', cex=.7)
    segments(Fulbright$time, Fulbright$IRT_2.5Q, Fulbright$time, Fulbright$IRT_97.5Q, col='blue')
    segments(Fulbright$time, Fulbright$DW_NOM1 + 2*Fulbright$DW_NOM1_se, Fulbright$time, Fulbright$DW_NOM1 - 2*Fulbright$DW_NOM1_se, col='black')
    text(max(Fulbright$time)+2, Fulbright$IRT_mean[length(Fulbright$IRT_mean)], label="Fulbright (D)", cex=.7)

    points(Dirksen$time, Dirksen$IRT_mean,  type='o', lty=1, col='red', cex=.7)
    points(Dirksen$time, Dirksen$DW_NOM1,  type='o', lty=2, col='black', cex=.7)
    segments(Dirksen$time, Dirksen$IRT_2.5Q, Dirksen$time, Dirksen$IRT_97.5Q, col='red')
    segments(Dirksen$time, Dirksen$DW_NOM1 + 2*Dirksen$DW_NOM1_se, Dirksen$time, Dirksen$DW_NOM1 - 2*Dirksen$DW_NOM1_se, col='black')
    text(max(Dirksen$time)+1.8, Dirksen$IRT_mean[length(Dirksen$IRT_mean)], label="Dirksen (R)", cex=.7)

    dev.off()


